import static org.junit.Assert.*;
import junit.framework.TestCase;

import org.junit.Test;

public class TestTrain extends TestCase {
	public void testConstructor() {
		ClockTime c1 = new ClockTime(10, 30);
		ClockTime c2 = new ClockTime(12, 00);
		ClockTime c3 = new ClockTime(15, 15);
		Schedule s1 = new Schedule(c1, c2);
		Schedule s2 = new Schedule(c1, c3);
		Schedule s3 = new Schedule(c2, c3);
		Route r1 = new Route("da nang", "ha noi");
		Route r2 = new Route("sai gon", "hue");
		Route r3 = new Route("sai gon", "ha noi");
		Train t1 = new Train(r1, s1, "la");
		Train t2 = new Train(r2, s2, "dn");
		Train t3 = new Train(r3, s3, "tphcm");
	}

	public void testKTDiemDen() {
		ClockTime c1 = new ClockTime(10, 30);
		ClockTime c2 = new ClockTime(12, 00);
		ClockTime c3 = new ClockTime(15, 15);
		Schedule s1 = new Schedule(c1, c2);
		Schedule s2 = new Schedule(c1, c3);
		Schedule s3 = new Schedule(c2, c3);
		Route r1 = new Route("da nang", "ha noi");
		Route r2 = new Route("sai gon", "hue");
		Route r3 = new Route("sai gon", "hanoi");
		Train t1 = new Train(r1, s1, "la");
		Train t2 = new Train(r2, s2, "dn");
		Train t3 = new Train(r3, s3, "tphcm");
		assertTrue(r2.KTDiemDen("hue"));
		assertTrue(r1.KTDiemDen("ha noi"));
		assertFalse(r3.KTDiemDen("hai phong"));
	}

	public void testTGTBD() {
		ClockTime c1 = new ClockTime(10, 30);
		ClockTime c2 = new ClockTime(12, 00);
		ClockTime c3 = new ClockTime(15, 15);
		Schedule s1 = new Schedule(c1, c2);
		Schedule s2 = new Schedule(c1, c3);
		Schedule s3 = new Schedule(c2, c3);
		Route r1 = new Route("da nang", "ha noi");
		Route r2 = new Route("sai gon", "hue");
		Route r3 = new Route("sai gon", "hanoi");
		Train t1 = new Train(r1, s1, "la");
		Train t2 = new Train(r2, s2, "dn");
		Train t3 = new Train(r3, s3, "tphcm");
		assertFalse(t1.TGTBD(c2));
		assertTrue(t1.TGTBD(c1));

	}

	public void testTGMat() {
		ClockTime c1 = new ClockTime(10, 30);
		ClockTime c2 = new ClockTime(12, 00);
		ClockTime c3 = new ClockTime(15, 15);
		Schedule s1 = new Schedule(c1, c2);
		Schedule s2 = new Schedule(c1, c3);
		Schedule s3 = new Schedule(c2, c3);
		Route r1 = new Route("da nang", "ha noi");
		Route r2 = new Route("sai gon", "hue");
		Route r3 = new Route("sai gon", "hanoi");
		Train t1 = new Train(r1, s1, "la");
		Train t2 = new Train(r2, s2, "dn");
		Train t3 = new Train(r3, s3, "tphcm");
		ClockTime cl1 = new ClockTime(2, 0);
		assertEquals(t1.TGMat(), 90, 0.01);
		assertEquals(t3.TGMat(), 195, 0.01);

	}

}
